package com.beta.support;

import com.beta.dto.product.ProductItemOptions;
import com.beta.dto.product.ProductPropertiesDto;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;

/**
 * Created by vector on 2017/2/7.
 */
public abstract class ProductPropertiesUtil {

    private ProductPropertiesUtil() {

    }

    public static String getOrigin(List<ProductPropertiesDto> productProperties) {
        if (CollectionUtils.isEmpty(productProperties)) {
            return "";
        }
        for (ProductPropertiesDto pro : productProperties) {
            if (pro.getName().equals("origin")) {
                return pro.getValue();
            }
        }
        return "";
    }

    public static String getLevel(List<ProductItemOptions> productOptions) {
        if (CollectionUtils.isEmpty(productOptions)) {
            return "";
        }

        for (ProductItemOptions pro : productOptions) {
            if (pro.getName().equals("level"))
                return pro.getValuePresentation();
        }
        return "";
    }

}
